$(function() {
	
	banner2();
  function banner2(){
  	var obj = JSON.parse(localStorage.getItem("companyStore"));//localStorage获取出来
	  var str =''
	  		for(var i=0;i<obj.length;i++){
	  			if(i == 0){
	  				str +='<li class="ani" style="margin-left: 0px;" swiper-animate-effect="fadeIn" swiper-animate-duration="1s" swiper-animate-delay="1s">'
	    		}else{
	  				str +='<li class="ani" swiper-animate-effect="fadeIn" swiper-animate-duration="1s" swiper-animate-delay="1s">'
	    		}
	    		str +='<img src="'+obj[i].img+'" />'
	    			str +='<div class="listbox">'
	    			 $.each(obj[i].desc, function(index,item) {
	    			 	str +='<p>'+item+'</p>'
	    			 });
	    			str +='</div>'
	    		str +='</li>'
	  		}
	  $(".banner2 ul").html(str)
  };

	
	
  // banner-4
  banner4();
  function banner4(){
    get_information()   //请求资讯
    function get_information(){
      var nes_url = jumpUrl+"/knowledge/most_liked?rows_per_page=5";
      var loading = '<div class="loading">加载中...</div>';
      $(".banner4 ul").html(loading);
      $.get(nes_url,function(){
        },"json").error(function(data){
            layer.msg("请求失败")
        }).success(function(data){
          $(".loading").remove()
          var obj = data.data;
          var infomaxlength = 60;
          var titlemaxlength = 26;
          console.info(obj);
          var str =''
          		for(var i=0;i<5;i++){
          			if(obj[i].title.length>titlemaxlength){
          			 obj[i].title = obj[i].title.substring(0,titlemaxlength-3)+'...';
          			}else{
          				obj[i].title = obj[i].title
          			}
          			if(obj[i].info.length>infomaxlength){
          			 obj[i].info = obj[i].info.substring(0,infomaxlength-3)+'...';
          			}else{
          				obj[i].info = obj[i].info
          			}
          			if(i == 0){
          				str +='<li class="firstLi">'
	                	str +='<a href="'+jumpUrl+'/knowledge/'+obj[i].id+'/view">'
	            			str +='<img src="'+obj[i].img+'" width="300" height="160" />'
		            		str +='<div class="infobox oh bgColor">'
		            			str +='<div class="fl" style="width: 550px;">'
			            			str +='<p class="font14 colorE" style="margin-bottom:5px">'+obj[i].title+'</p>'
			            			str +='<p class="font12 colorF">'+obj[i].info+'</p>'
		            			str +='</div>'
		            			str +='<div class="fr textar">'
		            				str +='<p class="font16 colorE">10:12</p>'
		            				str +='<p class="font12">2015</p>'
		            			str +='</div>'
		            		str +='</div>'
		            		str +='</a>'
	            		str +='</li>'
          			}else{
          				if(i == 1|| i == 3){
          					str +='<li style="margin-right:40px;">'
          				}else{
          					str +='<li>'
          				}
	            			str +='<a href="'+jumpUrl+'/knowledge/'+obj[i].id+'/view">'
	            			str +='<div class="listli">'
	            				str +='<p class="font16">'+obj[i].time+'</p>'
	            				str +='<p class="font12">'+obj[i].year+'</p>'
	            			str +='</div>'
	            			str +='<div class="listinfobox">'
	            				str +='<p class="font14 colorE" style="margin-bottom:5px">'+obj[i].title+'</p>'
			            		str +='<p class="font12 colorF">'+obj[i].info+'</p>'
			            		str +='</div>'
	            			str +='</a>'
	            		str +='</li>'
          			}
          		}

          $(".banner4 ul").html(str)
        });
    };
  };
  
  banner5();
  function banner5(){
      var nes_url = jumpUrl+"/api/index/show";
      var loading = '<div class="loading">加载中...</div>';
      $(".banner4 ul").html(loading);
      $.get(nes_url,function(){
        },"json").error(function(data){
            layer.msg("请求失败")
        }).success(function(data){
          $(".loading").remove()
          var obj = data.data;
          var str =''
          		for(var i=0;i<obj.length;i++){
          			if(i == 3){
          				str +='<div class="swiper-slide swiper-slide-active" style="background-image:url('+obj[i].img+')"></div>'
          			}else{
          				str +='<div class="swiper-slide" style="background-image:url('+obj[i].img+')"></div>'
          			}
          		}
          $(".banner5 .swiper-container5 .swiper-wrapper").html(str)
          
          var str2 =''
          		for(var i=0;i<obj.length;i++){
          			if(i == 3){
          			str2 +='<li style="display: block;"><p class="lvname">'+obj[i].title+'</p><p>'+obj[i].home+'</p><p class="lvinfoview">'+obj[i].desc+'</p></li>'
          			}else{
          				str2 +='<li><p class="lvname">'+obj[i].title+'</p><p>'+obj[i].home+'</p><p class="lvinfoview">'+obj[i].desc+'</p></li>'
          			}
          		}
          $(".banner5 .lvinfoboxs").html(str2)
          var mySwiper5 = new Swiper('.swiper-container5', {
						prevButton:'.icon-button-prev5',
						nextButton:'.icon-button-next5',
					    effect: 'coverflow',
					    initialSlide :3,
					    grabCursor: true,
					    centeredSlides: true,
					    slidesPerView: 'auto',
					    coverflow: {
					        rotate:0,
					        stretch: 10,
					        depth:50,
					        modifier:0,
					        slideShadows : true,
					    }
					});
					$('.icon-button-prev5,.icon-button-next5').click(function(){
						var showindex = mySwiper5.activeIndex;
						if(showindex == 0){//判断最后一个滑动
							$(".icon-button-prev5").hide();
						}else if(showindex == 6){
							$(".icon-button-next5").hide();
						}else{
							$(".icon-button-prev5").show();
							$(".icon-button-next5").show();
						}
						$(".lvinfoboxs li").hide().eq(showindex).show();
					})
      });
  };
  banner6();
  function banner6(){
      var nes_url = jumpUrl+"/api/index/good";
      var loading = '<div class="loading">加载中...</div>';
      $(".banner4 ul").html(loading);
      $.get(nes_url,function(){
        },"json").error(function(data){
            layer.msg("请求失败")
        }).success(function(data){
          $(".loading").remove()
          var obj = data.data;
          var str =''
          		for(var i=0;i<obj.length;i++){
          			str +='<div class="swiper-slide ani" swiper-animate-effect="fadeIn" swiper-animate-duration="1s" swiper-animate-delay="0.5s">'
					        	str +='<div class="banner6-title">'+obj[i].desc+'</div>'
			            		str +='<div class="banner6-info">'
			            			str +='<img src="'+obj[i].img+'" width="100" height="100"/>'
			            			str +='<p class="banner6-lv-name"><span>'+obj[i].title+'</span></p>'
			            			str +='<p class="font16">'+obj[i].home+'</p>'
			            		str +='</div>'
					        str +='</div>'
          		}
          $(".banner6 .swiper-container6 .swiper-wrapper").html(str)
          
          
          
        var mySwiper6 = new Swiper('.swiper-container6',{
					prevButton:'.icon-button-prev',
					nextButton:'.icon-button-next',
					onInit: function(swiper){ //Swiper2.x的初始化是onFirstInit
					    
					}, 
					onSlideChangeEnd: function(swiper){ 
						if(mySwiper6.isEnd){//判断最后一个滑动
							$(".icon-button-next").hide();
						}else{
							$(".icon-button-next").show();
						}
						if(mySwiper6.isBeginning){//判断最后一个滑动
							$(".icon-button-prev").hide();
						}else{
							$(".icon-button-prev").show();
						}
					},
				})
        
      });
  };

  
});

